package com.ruoyi.project.system.manager.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.manager.domain.Manager;
import com.ruoyi.project.system.manager.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 公告管理控制类
 */
@Controller
@RequestMapping("/system/manager")
public class ManagerController extends BaseController {

    private String prefix = "system/manager";

    @Autowired
    private ManagerService managerService;

    @GetMapping()
    public String notice() {
        return prefix + "/manager";
    }

    /**
     * 根据调价查询所有申请
     *
     * @return
     */
    @PostMapping("list")
    @ResponseBody
    public TableDataInfo managerList(String title) {
        startPage();
        List<Manager> managers = managerService.selectAllManager(title);
        return getDataTable(managers);
    }


    /**
     * 批量删除公告信息
     *
     * @param ids
     * @return
     */
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(managerService.removeById(ids));
    }

    /**
     * 跳转增加页面
     *
     * @return
     */
    @GetMapping("/toAdd")
    public String toAdd() {
        return prefix + "/add";
    }

    /**
     * 跳转编辑页面
     * @return
     */
    @GetMapping("/edit/{id}")
    public String toEdit(@PathVariable("id")Long id, ModelMap mmap){
        mmap.put("manager", managerService.queryManagerById(id));
        return prefix + "/edit";
    }

    /**
     * 编辑
     * @return
     */
    @GetMapping("/edit")
    public AjaxResult edit(Manager manager, ModelMap mmap){

        return null;
    }

    /**
     * 查看
     * @return
     */
    @GetMapping("/detail/{id}")
    public String detail(@PathVariable("id") Long id, ModelMap mmap){
        mmap.put("manager", managerService.queryManagerById(id));
        return prefix + "/details";
    }



}
